package com.ruoyi;

import org.springframework.beans.factory.annotation.Value;

import java.sql.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class MyJdbc {

    public static void main(String[] args) {
        String sql = "ygdm, ssfzjgdm, ygxm, xb, mz, csrq, zzmm, cjzdrq, zjlx, zjhm, lxdh, xl, zyjszg, djgbz, gw, rsrq, lsrq," +
                "insert_time, del_flag,date_id";

        String result = sql.replace(" ", "");
        System.out.println(result);
//        String batchno = "20240630";
//        System.out.println(batchno.substring(0,4));
//        System.out.println(batchno.substring(4,6));
//        System.out.println(batchno.substring(6,8));
//
//        String year = batchno.substring(0,4);
//        String month = batchno.substring(4,6);
//        String day = batchno.substring(6,8);
//
//        String start= year+"-"+month+"-"+day+" 00:00:00";
//        String end = year+"-"+month+"-"+day+" 23:59:59";
     //   f1();
    }

    public static void f1(){

         String url = "jdbc:mysql://192.168.101.130:3306/ry-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8";// = "jdbc:oracle:thin:@10.57.37.73:2632/ora11g";

         String user="root"; // = "east_user";

        String password="abcd1234";// = "Ob4#!Ct8Gk6";

        Connection conn = null;
        PreparedStatement stmt = null;
        try {
            Class.forName("com.mysql.cj.jdbc.Driver");
            conn = DriverManager.getConnection(url, user, password);
            System.out.println("Connected to the Oracle server");

            // 4. 执行SQL语句

            stmt = conn.prepareStatement("select count(*) as total from sys_user");
//            stmt.setString(1, userid);
//            stmt.setString(2, tablename);


            ResultSet rs = stmt.executeQuery();


            int rowCount = 0;
            if(rs.next())
            {
                //   rowCount=rs.getInt("record_");
                rowCount = rs.getInt(1);
            }

            System.out.println(rowCount);

        } catch (ClassNotFoundException e) {
            System.out.println("Oracle JDBC driver not found");
            e.printStackTrace();

        } catch (SQLException e) {
            System.out.println("Connection to Oracle failed");
            e.printStackTrace();

        } finally {
            if (conn != null) {
                try {
                    conn.close();
                } catch (SQLException e) {
                    e.printStackTrace();
                }
            }
        }

    }
}
